package com.atguigu.gmall.web.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.order.client.OrderFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.Map;

/**
 * @Author atguigu-mqx
 * @Description TODO
 * @Date 2023/7/22 14:39
 * @Version 1.0
 */
@Controller
public class OrderController {

    @Autowired
    private OrderFeignClient orderFeignClient;

    /**
     * 订单结算页展示
     * @param model
     * @return
     */
    @GetMapping("trade.html")
    public String trade(Model model){
        //  detailArrayList totalNum totalAmount ---> 将这些数据存储到实现类的map中。根据商品 详情一样！
        Result<Map> result = orderFeignClient.authTrade();
        //  存储数据
        model.addAllAttributes( result.getData());
        //  返回订单结算页.
        return "order/trade";
    }

    /**
     * 我的订单
     * @return
     */
    @GetMapping("myOrder.html")
    public String myOrder(){
        //  我的订单页面.
        return "order/myOrder";
    }
}
